package com.boarsoft.boar.batch.bean;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.boarsoft.boar.batch.entity.BatchExecution;
import com.boarsoft.common.util.InetUtil;

public class BatchAppStat implements Serializable {
	private static final long serialVersionUID = -6331986369674101949L;

	protected String catalog;

	protected String addr;

	protected short status;

	protected Map<String, List<BatchExecution>> instMap = new HashMap<String, List<BatchExecution>>();

	public BatchAppStat(String catalog) {
		this.catalog = catalog;
		this.addr = InetUtil.getAddr();
	}

	public BatchAppStat(String catalog, String addr, short status) {
		this.catalog = catalog;
		this.addr = addr;
		this.status = status;
	}

	public void addInst(BatchExecution execution) {
		String k = execution.getCode();
		List<BatchExecution> lt = instMap.get(k);
		if (lt == null) {
			lt = new ArrayList<BatchExecution>();
			instMap.put(k, lt);
		}
		lt.add(execution);
	}

	public Map<String, List<BatchExecution>> getInstMap() {
		return instMap;
	}

	public void setInstMap(Map<String, List<BatchExecution>> instMap) {
		this.instMap = instMap;
	}

	public String getAddr() {
		return addr;
	}

	public void setAddr(String addr) {
		this.addr = addr;
	}

	public short getStatus() {
		return status;
	}

	public void setStatus(short status) {
		this.status = status;
	}

	public String getCatalog() {
		return catalog;
	}

	public void setCatalog(String catalog) {
		this.catalog = catalog;
	}
}
